/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import interfaces.GGInterface;
import interfaces.KundeInterface;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author Jonas
 */
public class GG extends UnicastRemoteObject implements GGInterface {

    private Statement stmt;
    private ResultSet rs;

    public GG() throws RemoteException {
        super();
    }

    @Override
    public KundeInterface login(int id, String pw) throws RemoteException {
        String sql = "call getKunde(" + id + ", " + pw + ")";
        Kunde kd = null;
        try {
            rs = Main.dh.getStmt().executeQuery(sql);
            while (rs.next()) {
                kd = new Kunde(rs.getInt("kunde_id"), rs.getString("kunde_navn"), rs.getString("kunde_kodeord"));
                System.out.println("Jeg har fundet et login\n\n");
            }
        } catch (SQLException ex) {
            System.out.println("SQL fejl");
        }
        return kd;
    }
}
